home *** CD-ROM | disk | FTP | other *** search
- class MissileLauncher
- {
- var index;
- var bmpBase;
- var bmpHead;
- var bmpExplode;
- var bmpCanvas;
- var position;
- var VEL;
- var energy;
- var frameExp;
- var shotDelay;
- var bOnScreen;
- var bFlash;
- var rotation;
- var screenPos;
- var maxRot = 2.356194490192345;
- var minRot = 0.7853981633974483;
- function MissileLauncher(pos, type, indexNew)
- {
- this.index = indexNew;
- this.bmpBase = flash.display.BitmapData.loadBitmap("ml base");
- this.bmpHead = flash.display.BitmapData.loadBitmap("ml head");
- this.bmpExplode = flash.display.BitmapData.loadBitmap("explosion0");
- this.bmpCanvas = Game.bmpDead;
- this.position = pos.clone();
- this.VEL = 10;
- this.energy = 5;
- this.frameExp = 0;
- this.shotDelay = Math.round(10 * Math.random());
- this.bOnScreen = false;
- this.bFlash = false;
- }
- function getPosition(Void)
- {
- return this.position.clone();
- }
- function step(chopperPos, chopperVel, aShots)
- {
- if(!this.bOnScreen && this.energy > 0)
- {
- return undefined;
- }
- var _loc4_ = aShots.length;
- var _loc3_ = 0;
- while(_loc3_ < _loc4_)
- {
- var _loc2_ = Shot(aShots[_loc3_]);
- var _loc7_ = _loc2_.position.x - this.position.x;
- var _loc6_ = _loc2_.position.y - this.position.y;
- if(_loc7_ * _loc7_ + _loc6_ * _loc6_ < 400)
- {
- Game.getInstance().removeAllyShot(_loc2_);
- this.energy = this.energy - 1;
- this.bFlash = true;
- Game.getInstance().createShrapnel(_loc2_.position);
- if(this.energy == 0)
- {
- Game.getInstance().saveHostileInd(this.index);
- Game.getInstance().addPoints(this.position,500);
- Sounds.playSound("bazooka");
- trace("destroyed");
- }
- break;
- }
- _loc3_ = _loc3_ + 1;
- }
- _loc7_ = chopperPos.x - this.position.x;
- _loc6_ = chopperPos.y - this.position.y;
- this.rotation = Math.atan2(_loc6_,_loc7_);
- if(this.rotation > this.maxRot)
- {
- this.rotation = this.maxRot;
- }
- else if(this.rotation < this.minRot)
- {
- this.rotation = this.minRot;
- }
- if(this.shotDelay-- <= 0)
- {
- this.shotDelay = 90 + Math.round(60 * Math.random());
- var _loc8_ = new flash.geom.Point(this.position.x + 30 * Math.cos(this.rotation),this.position.y + 30 * Math.sin(this.rotation));
- Game.getInstance().createMissile(false,_loc8_,null);
- Sounds.playSound("missile_snd");
- }
- }
- function draw(leftEdge)
- {
- var _loc8_ = this.position.x - leftEdge - this.bmpBase.width / 2;
- var _loc7_ = this.position.y + this.bmpBase.height / 2;
- this.screenPos = new flash.geom.Point(_loc8_,_loc7_);
- if(_loc8_ > (- this.bmpBase.width) * 1 && _loc8_ < Game.screenW + this.bmpBase.width * 0.5)
- {
- this.bOnScreen = true;
- if(this.energy > 0)
- {
- var _loc2_ = new flash.display.BitmapData(this.bmpHead.width,this.bmpHead.height,true,0);
- _loc2_.copyPixels(this.bmpHead,this.bmpHead.rectangle,new flash.geom.Point(0,0),null,null,true);
- var _loc3_ = new flash.geom.Matrix();
- _loc3_.translate((- _loc2_.width) / 2,(- _loc2_.height) / 2);
- var _loc6_ = new flash.geom.Matrix();
- _loc6_.rotate(- this.rotation);
- _loc3_.concat(_loc6_);
- var _loc5_ = new flash.geom.Matrix();
- _loc5_.translate(_loc8_ + this.bmpBase.width * 0.5,Game.screenH - (_loc7_ - this.bmpBase.height + 22));
- _loc3_.concat(_loc5_);
- var _loc9_ = !this.bFlash ? null : new flash.geom.ColorTransform(0,0,0,0,255,255,255,255);
- this.bmpCanvas.draw(_loc2_,_loc3_,_loc9_,null,null,true);
- var _loc4_ = this.bmpBase.clone();
- if(this.bFlash)
- {
- _loc4_.colorTransform(_loc4_.rectangle,new flash.geom.ColorTransform(0,0,0,0,255,255,255,255));
- }
- this.bmpCanvas.copyPixels(_loc4_,_loc4_.rectangle,new flash.geom.Point(this.screenPos.x,Game.screenH - this.screenPos.y),null,null,true);
- this.bFlash = false;
- }
- else
- {
- _loc8_ = this.position.x - leftEdge;
- _loc7_ = this.position.y;
- this.screenPos = new flash.geom.Point(_loc8_,_loc7_);
- this.drawExplosion(this.screenPos,true);
- }
- }
- else
- {
- this.bOnScreen = false;
- }
- }
- function drawExplosion(pos, bRemove)
- {
- var _loc3_ = _root.attachMovie("explosion2","mcExp",_root.getNextHighestDepth());
- _loc3_.gotoAndStop(this.frameExp + 1);
- var _loc4_ = new flash.geom.Matrix();
- _loc4_.translate(pos.x,Game.screenH - pos.y);
- this.bmpCanvas.draw(_loc3_,_loc4_,null,null,null,true);
- _loc3_.removeMovieClip();
- this.frameExp = this.frameExp + 1;
- if(this.frameExp == 27)
- {
- if(bRemove)
- {
- this.onEndDeadAnim();
- }
- }
- }
- function onEndDeadAnim(Void)
- {
- Game.getInstance().removeHostile(this);
- }
- }
-